package easyway.trainapp.webaccess.testweb;

import java.io.IOException;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.ejb.EJBException;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletResponse;

import easyway.train.testejb.domain.Testejb;
import easyway.train.testejb.ejb.bean.TestejbBean;
import easyway.train.testejb.ejb.faces.TestejbRemote;
import easyway.trainapp.webframework.util.BasicBackingBean;
import easyway.trainapp.webframework.util.EJBLookup;

public class TestwebBB extends BasicBackingBean {

	// 查询条件始
	private String id; 
	private String username ; 
	private String userage; 
	
	private List<Testejb> testwebList;
	
	private static TestejbRemote answerbankremote;


	static {
		try {
			answerbankremote = (TestejbRemote) EJBLookup.getEJBRemote(TestejbBean.class);
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}
	
	public String query() { // 条件查询问题信息数据集合
		try {
			map = new HashMap<String, Serializable>();
			
			if(id!=null&&!"".equals(id)){
				map.put("id", id);
			}
			if(username!=null&&!"".equals(username)){
				map.put("username", username);
			}
			if(userage!=null&&!"".equals(userage)){
				map.put("userage", userage);
			}
		
			testwebList = answerbankremote.queryTestejbByMap(map);
			if (testwebList.size() == 0) {
				this.setMsg("无查询结果");
				return "";
			}
		} catch (Exception e) {
			this.addMsg("操作失败，请联系管理员！");
			e.printStackTrace();
			logger.error("查询问题信息时出错", e);
			return "";
		}
		return "";
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUserage() {
		return userage;
	}

	public void setUserage(String userage) {
		this.userage = userage;
	}

	public List<Testejb> getTestwebList() {
		return testwebList;
	}

	public void setTestwebList(List<Testejb> testwebList) {
		this.testwebList = testwebList;
	}

}
